package com.sgb.kjwl.view.ui.fragment.chat;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;

import com.hotpot.uikit.talk.MessageListFragment;
import com.sgb.kjwl.AppLazyFragment;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.FrNewsChildViewBinding;
import com.im.immodel.IMUtils;

public class NewsChildFragment extends AppLazyFragment {

    private FrNewsChildViewBinding binding;

    public static NewsChildFragment newInstance() {
        NewsChildFragment dialog = new NewsChildFragment();
        return dialog;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = DataBindingUtil.inflate(inflater, R.layout.fr_news_child_view, container, false);
        return binding.getRoot();
    }

    @Override
    protected void initView() {
        binding.editSearch.setOnClickListener(this);

        getChildFragmentManager()
                .beginTransaction()
                .add(R.id.container, new MessageListFragment())
                .commitAllowingStateLoss();

        //获取会话列表并刷新数据库
        IMUtils.getInstance().refreshMessage();
    }

    @Override
    protected void onLazyLoad() {

    }



    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.edit_search:
                IMUtils.getInstance().startSearch();
                break;
        }
    }
}
